﻿namespace NumeralSystems
{
    using System;
    using System.Collections.Generic;

    class ConvertRandomBinToHex
    {
        // 1.1.8.09. Write a program that converts a binary number to hexadecimal one. (directly)

        public static string ConvertBinToHex(string binNum)
        {
            int fullBinCount = 0;
            if (binNum.Length % 4 == 0)
            {
                fullBinCount = binNum.Length;
            }
            else
            {
                fullBinCount = ((binNum.Length / 4) + 1) * 4;
            }

            char[] fullBinNum = new char[fullBinCount];
            for (int i = 0; i < fullBinNum.Length - binNum.Length; i++)
            {
                fullBinNum[i] = '0';
            }
            for (int i = 0; i < binNum.Length; i++)
            {
                fullBinNum[i + fullBinNum.Length - binNum.Length] = binNum[i];
            }

            List<char> fullBinList = new List<char>();
            for (int i = 0; i < fullBinNum.Length; i++)
            {
                fullBinList.Add(fullBinNum[i]);
            }

            List<string> foursBins = new List<string>();
            for (int i = 0; i < fullBinList.Count; i += 4)
            {
                List<char> fourBins = new List<char>();
                fourBins = fullBinList.GetRange(i, 4);
                foursBins.Add(String.Join("", fourBins));
            }

            char[] hexCompilation = new char[foursBins.Count];

            for (int i = 0; i < foursBins.Count; i++)
            {
                int numAsDecimal = 0;
                for (int j = 0; j < foursBins[i].Length; j++)
                {
                    if (foursBins[i][foursBins[i].Length - 1 - j] == '1')
                    {
                        numAsDecimal += 1 * CalculatePower(2, j);
                    }
                }

                if (numAsDecimal == 0)
                {
                    hexCompilation[i] = '0';
                }
                else if (numAsDecimal == 1)
                {
                    hexCompilation[i] = '1';
                }
                else if (numAsDecimal == 2)
                {
                    hexCompilation[i] = '2';
                }
                else if (numAsDecimal == 3)
                {
                    hexCompilation[i] = '3';
                }
                else if (numAsDecimal == 4)
                {
                    hexCompilation[i] = '4';
                }
                else if (numAsDecimal == 5)
                {
                    hexCompilation[i] = '5';
                }
                else if (numAsDecimal == 6)
                {
                    hexCompilation[i] = '6';
                }
                else if (numAsDecimal == 7)
                {
                    hexCompilation[i] = '7';
                }
                else if (numAsDecimal == 8)
                {
                    hexCompilation[i] = '8';
                }
                else if (numAsDecimal == 9)
                {
                    hexCompilation[i] = '9';
                }
                else if (numAsDecimal == 10)
                {
                    hexCompilation[i] = 'A';
                }
                else if (numAsDecimal == 11)
                {
                    hexCompilation[i] = 'B';
                }
                else if (numAsDecimal == 12)
                {
                    hexCompilation[i] = 'C';
                }
                else if (numAsDecimal == 13)
                {
                    hexCompilation[i] = 'D';
                }
                else if (numAsDecimal == 14)
                {
                    hexCompilation[i] = 'E';
                }
                else if (numAsDecimal == 15)
                {
                    hexCompilation[i] = 'F';
                }
                else
                {
                    throw new Exception("Error");
                }
            }

            return String.Join("", hexCompilation);
        }

        public static int CalculatePower(int num, int power)
        {
            int result = 1;
            for (int i = 0; i < power; i++)
            {
                result *= num;
            }

            return result;
        }

        static void Main()
        {
            string binNum = Console.ReadLine();
            Console.WriteLine(ConvertBinToHex(binNum));
        }
    }
}